
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>FreeMarker - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>FreeMarker - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">FreeMarker是什么？它的主要设计用途是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">FreeMarker是一个用纯Java编写的模板引擎，一个基于模板生成文本输出的通用工具。它被设计用来生成HTML Web页面，尤其适用于基于MVC模式的应用程序。</div>
          </div>
          <div class="card-source">来源: 1. 介绍</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">FreeMarker的核心工作流程是怎样的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">其核心工作流程是“模板 + 数据模型 = 输出页面”。通常由Java程序准备要显示的数据（数据模型），然后FreeMarker通过模板来显示这些准备好的数据，最终生成文本输出（如HTML页面）。</div>
          </div>
          <div class="card-source">来源: 1. 介绍</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在SpringBoot项目中使用FreeMarker，需要引入哪个关键的依赖？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">需要在项目中引入`spring-boot-starter-freemarker`依赖。</div>
          </div>
          <div class="card-source">来源: 2. 快速使用</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">语法</div>
          <div class="card-question">在FreeMarker模板中，如何遍历一个集合并获取当前项的索引？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">语法</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">使用`<#list ...>`指令进行遍历。例如：`<#list list as stu> ... </#list>`。在循环体内，可以通过`${stu_index}`来获取当前遍历项的索引。</div>
          </div>
          <div class="card-source">来源: 3. 基本操作</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">语法</div>
          <div class="card-question">文档中介绍了哪两种处理NULL值的方法？请举例说明。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">语法</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档介绍了两种方法：1. 使用`!`提供默认值，如果变量为null，则显示`!`后的值，例如`${email!''}`。2. 使用`??`判断值是否存在，例如`<#if nullObject??> ... </#if>`来判断`nullObject`是否为null。</div>
          </div>
          <div class="card-source">来源: 3. 基本操作</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">语法</div>
          <div class="card-question">FreeMarker中实现if-elseif-else逻辑判断的语法结构是怎样的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">语法</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">使用`<#if>`、`<#elseif>`和`<#else>`指令。基本结构为：`<#if (age > 40)>大叔级<#elseif (age > 30)>老腊肉<#else>小鲜肉</#if>`。</div>
          </div>
          <div class="card-source">来源: 3. 基本操作</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">实现</div>
          <div class="card-question">在Java代码中，通过FreeMarker生成静态文件的核心步骤有哪些？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">实现</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">根据文档中的Controller示例，核心步骤包括：获取模板（`configuration.getTemplate`）、设置生成文件的输出路径（`new FileWriter(...)`）以及执行生成操作（`template.process(map, fileWriter)`）。</div>
          </div>
          <div class="card-source">来源: 4. 生成单个商品的静态页面 - Controller</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">实现</div>
          <div class="card-question">在Java后端向FreeMarker模板传递数据时，通常使用什么类型的数据结构？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">实现</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通常使用一个`Map<String, Object>`对象。在这个Map中，键（Key）作为模板中可访问的变量名，值（Value）则是这些变量对应的数据。</div>
          </div>
          <div class="card-source">来源: 4. 生成单个商品的静态页面 - Controller</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">语法</div>
          <div class="card-question">在FreeMarker中，访问对象属性和使用三元表达式的语法分别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">语法</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">访问对象属性使用点（.）运算符，如 `${stu.name}`。三元表达式的语法为 `${(condition) ? string('true_value', 'false_value')}`，例如 `${(user.sex == 1) ? string('男', '女')}`。</div>
          </div>
          <div class="card-source">来源: 3. 基本操作</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
